package com.tianlh.service.aspect;

import com.tianlh.entity.Book;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 *
 * @author wb-tianlihui
 * @date 2017/12/20
 */
@Aspect
@Component
public class SsmAspect implements ApplicationContextAware {

    private ApplicationContext applicationContext;


    public SsmAspect() {
    }

    @Around(value = "@annotation(aspectPoint)")
    public Book doExternalAPI(final ProceedingJoinPoint pjp, AspectPoint aspectPoint) throws Throwable {
        System.out.println(aspectPoint.name());
        return (Book)pjp.proceed();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
